"use client";

import { loadOml2d } from "oh-my-live2d";
import { useEffect, useState } from "react";

const Live2D: React.FC = () => {
  const [loaded, setLoaded] = useState(false);
  useEffect(() => {
    if (loaded) {
    } else {
      const oml2d = loadOml2d({
        models: [
          {
            path: "https://model.oml2d.com/shizuku/shizuku.model.json",
            scale: 0.2,
            volume: 0,
            position: [70, 70],
            stageStyle: {
              height: 370,
              width: 400,
            },
          },
        ],
      });
      oml2d.onLoad(status => {
        switch (status) {
          case "success":
            console.log("加载成功");
            setLoaded(true);
            return;
          case "fail":
            console.log("加载失败");
            return;
          case "loading":
            console.log("正在加载中");
            return;
        }
      });
    }
  }, [loaded]);

  return <></>;
};

export default Live2D;
